package com.lovo.service;

import com.lovo.dao.BaseDAO;
import com.lovo.model.UserDO;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

//@Data
@NoArgsConstructor
@Service
public class UserService {
    @Autowired
    @Qualifier(value = "userDO")
    private UserDO userDO;
    @Resource
    private BaseDAO baseDAO;

    @PostConstruct
    public void init(){
        System.out.println("UserService初始化");
    }
    @PreDestroy
    public void destroy(){
        System.out.println("UserService销毁");
    }

//    @Autowired
    public UserService(UserDO userDO,BaseDAO baseDAO){
        this.userDO = userDO;
        this.baseDAO = baseDAO;
    }
    public UserDO findById(String userId){
        System.out.println("baseDAO:" + baseDAO);
        return userDO;
    }


    public void setUserDO(UserDO userDO) {
        this.userDO = userDO;
    }

    public void setBaseDAO(BaseDAO baseDAO) {
        this.baseDAO = baseDAO;
    }
}
